/**
 * Copyright (C) 2015-2018 IQIYI
 * All rights reserved.
 *
 * Author     : 王海斌
 * E-mail     : wanghaibin@qiyi.com
 * Version    :
 * Date       : Tue 02 Jun 2020 01:49:19 PM CST
 * Destription: 获取uri对应的crc32信息
 */
#include <assert.h>
#include <getopt.h>

#include <acl-lib/acl/lib_acl.h>
#include <acl-lib/acl_cpp/lib_acl.hpp>


static void usage(const char* procname)
{
    printf("usage: %s -h[help]\r\n", procname);
    printf("options:\r\n");
    printf("\t-k uri         # 操作的uri\r\n");
}

int main(int argc, char* argv[])
{
    if(argc<2) {
        usage(argv[0]);
        return 0;
    }
    std::string uri;
    int   ch;
    while ((ch = getopt(argc, argv, "hk:")) > 0)
    {
        switch (ch)
        {
            case 'h':
                usage(argv[0]);
                return 0;
            case 'k':
                uri = optarg;
                break;
            default:
                usage(argv[0]);
                return 0;
        }
    }
    // 将日志输出至屏幕
    acl::log::stdout_open(true);
    unsigned int v = acl_hash_crc32(uri.c_str(), uri.size());
    printf("value=%u\n", v);

    return 0;
}
